<?php
/**
 * @link https://www.kancloud.cn/cleverstone/ymb2
 * @copyright Copyright (c) 2020 Yii Manager Software LLC
 */

namespace builder\bundle;

use builder\helper\App;
use Yii;

/**
 * ym v2.0
 * @author cleverstone
 * @since ym2.0
 */
class Ym2 extends BaseAsset
{
    public $css = [
        'ym2/ym2.common.css',
    ];

    public $js = [
        'ym2/ym2.js',               // 框架常用封装
        'ym2/ym2.bootstrap.js',     // 框架插件初始化
        'ym2/ym2.component.js',     // 框架自定义web component
        'ym2/ym2.context.js',       // 框架数据定义
    ];

    public $depends = [
        CoreAsset::class,
    ];

    /**
     * INIT
     */
    public function init()
    {
        parent::init();

        $viewParams = Yii::$app->view->params;
        $skin = !empty($viewParams['uiTheme']) ? $viewParams['uiTheme'] : 'ym2-theme-cyan';
        foreach (App::params('admin.viewTheme', []) as $value) {
            if ($skin == $value['key']) {
                $this->css[] = $value['css'];
                break;
            }
        }
    }
}